import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> map = new HashMap<>();
        List<String> list = new ArrayList<>();

        while (in.hasNext()) {
            String s = in.next();
            int n = in.nextInt();
            String[] strings = s.split("\\\\");
            s = strings[strings.length - 1];
            if (s.length() > 16) {
                s = s.substring(s.length() - 16);
            }
            s = s + " " + n;

            if (!map.containsKey(s)) {
                map.put(s, 1);
                list.add(s);
            } else {
                map.put(s, map.get(s)+1);
            }
        }

        if (list.size() <= 8) {
            for (String s : list) {
                System.out.println(s + " " + map.get(s));
            }
        } else {
            for (int i = list.size()-8; i < list.size(); i++) {
                System.out.println(list.get(i) + " " + map.get(list.get(i)));
            }
        }
    }

    // 数组中出现次数超过一半的数字
    public int MoreThanHalfNum_Solution(int[] numbers) {
        // write code here
        Map<Integer, Integer> map = new HashMap<>();

        if (numbers.length == 1) {
            return numbers[0];
        }
        for (int x : numbers) {
            if (!map.containsKey(x)) {
                map.put(x, 1);
            } else {
                map.put(x, map.get(x) + 1);
                if (map.get(x) >= numbers.length / 2) {
                    return x;
                }
            }
        }
        return -1;
    }
}
